package com.cskaoyan.weixin.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.mapper.BrandMapper;
import com.cskaoyan.weixin.bean.goods.*;
import com.cskaoyan.weixin.service.WXGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("wx/goods")
public class WxGoodsController {
    @Autowired
    WXGoodsService wxGoodsService;

    @RequestMapping("count")
    public BaseRespVo goodsCount() {
        GoodsCount goodscount = wxGoodsService.queryCount();
        return BaseRespVo.ok(goodscount);
    }

    @RequestMapping("detail")
    public BaseRespVo goodsDetail(Integer id) {
        WxGoodsDetail wxgoodsDetail = wxGoodsService.queryGoodsDetail(id);
        return BaseRespVo.ok(wxgoodsDetail);
    }

    @RequestMapping("category")
    public BaseRespVo goodsCategory(Integer id) {
        System.out.println(id);
        WxCategory wxCategory = wxGoodsService.queryGoodsCategory(id);
        return BaseRespVo.ok(wxCategory);
    }

    @RequestMapping("list")
    public BaseRespVo goodsList(Integer categoryId, Integer page, Integer size,String keyword) {
       WxGoodsList wxGoodsList = wxGoodsService.queryGoodsList(categoryId, page, size,keyword);
//    public BaseRespVo goodsList(Integer categoryId, Integer page, Integer size,
//                                String keyword, String sort, String order) {
      //  WxGoodsList wxGoodsList = wxGoodsService.queryGoodsList(categoryId, page, size, keyword, sort, order);
        return BaseRespVo.ok(wxGoodsList);
    }
    @RequestMapping("related")
    public  BaseRespVo related(Integer categoryId){
        List<GoodsListBean> goodsList=wxGoodsService.queryGoods(categoryId);
            return BaseRespVo.ok(goodsList);
        }

    }

